﻿using SmartSapce.ServiceLocation;
using SmartSpace.Core;
using SmartSpace.Web;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace SmartSpace.WebApp._console.wizzard
{
    public partial class create_application_administrator : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void _ctlBtnSave_Click(object sender, EventArgs e)
        {
            SmartSpace.Core.User user = new SmartSpace.Core.User();
            user.Id = Guid.NewGuid();
            user.Account = _ctlEditAccount.Text;
            user.Name = _ctlEditName.Text;
            user.Telphone = _ctlEditPhone.Text;
            user.Email = _ctlEditEmail.Text;
            user.Password = "123456";
            user.CreatedTime = DateTime.Now;

            ICoreService service = ServiceLocator.Get<ICoreService>();
            if (service.SaveUser(user))
            {

                SsSite.Application.SuperAdminUserId = user.Id;
                if (service.SaveApplication(SsSite.Application))
                {
                    Response.Redirect("../login.aspx");
                }
            }
        }
    }
}